package com.shop2cn.iapi.sqmarketing.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

public class SaveOrUpdaateMarketingActivityCall extends YmatouBaseCall{

	private static String opurl = "api/saveOrUpdaateMarketingActivity";

	public SaveOrUpdaateMarketingActivityCall() {
		super(EnvSetup.getSystemUrl("sqmarketing_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public int getCode() {
		int Code = 0;
		try {
			Code = new JSONObject(getReturnData()).getInt("code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取success
	 * 
	 * @return
	 */
	public Boolean getSuccess() {
		Boolean success = null;
		try {
			success = new JSONObject(getReturnData()).getBoolean("success");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return success;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public JSONObject getData() {
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("result");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}
	
	/**
	 * 获取id
	 * 
	 * @return
	 */
	public Long getId() {
		Long id = null;
		try {
			id = getData().getLong("id");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return id;
	}
}